#include <stdio.h>
#include <time.h>
#define MOD 1000000
int main()
{
    int n, sum = 0;
    scanf("%d", &n);
    if (n > 25){
        printf("940313\n");
        return 0;
    }
    for (int i = 1; i <= n; i++)
    {
        int f = 1;
        for (int j = 1; j <= i; j++)
        {
            f = (f * j) % MOD;
        }
        sum = (sum + f) % MOD;
    }
    printf("%d\n", sum);
    printf("Time used = %.2f\n", (double)clock() / CLOCKS_PER_SEC);
    return 0;
}